<script>
import { mapState } from 'vuex';

export default {
  data() {
    return {
      isShow: false,
      curItem: {},
    };
  },
  computed: {
    ...mapState({
      qfriends: (state) => state.config.qfriends || [],
    }),
  },
  methods: {
    handleClick(item) {
      this.curItem = item;
      this.isShow = true;
    },
  },
};
</script>

<template>
  <div class="dzq-index-section">
    <div class="dzq-index-section__hd">
      <h2 class="dzq-index-section__title"><span>Q 友说</span></h2>
    </div>
    <div class="dzq-index-section__bd dzq-qfriends">
      <div class="zdzq-row">
        <div v-for="(item, index) in qfriends" :key="index" class="zdzq-col-8">
          <div class="dzq-qfriends-item" @click="handleClick(item)">
            <div class="dzq-qfriends-header">
              <img :src="item.avatar" alt="avatar" class="dzq-qfriends-avatar" />
              <div class="dzq-qfriends-name">{{ item.name }}</div>
            </div>
            <div class="dzq-qfriends-desc">{{ item.desc }}</div>
          </div>
        </div>
      </div>
    </div>
    <dz-dialog v-model="isShow" :title="curItem.name" :title-img="curItem.avatar">
      {{ curItem.desc }}
    </dz-dialog>
  </div>
</template>

<style lang="scss">
.dzq-qfriends {
  margin-bottom: 60px;
  .zdzq-row {
    margin-right: -30px;
  }
  &-item {
    margin-right: 30px;
    margin-bottom: 30px;
    padding: 30px 30px 60px;
    background-image: linear-gradient(#f7fbff, #f7fbff), linear-gradient(#fff, #fff);
    background-blend-mode: normal, normal;
    box-shadow: 0 3px 7px 0 rgba(0, 110, 255, 0.16);
    cursor: pointer;
  }
  &-header {
    margin-bottom: 32px;
    display: flex;
    align-items: center;
  }
  &-avatar {
    margin-right: 20px;
    height: 51px;
    width: 51px;
    border-radius: 100%;
    background-color: #006eff;
  }
  &-name {
    font-size: 16px;
    font-weight: bold;
    color: #242d4e;
  }
  &-desc {
    height: 128px;
    font-size: 14px;
    line-height: 32px;
    letter-spacing: 0;
    text-align: justify;
    color: #91a2bb;

    @include text-ellipsis-multi-line(4);
  }
}

@media screen and (max-width: 768px) {
  .dzq-qfriends {
    .zdzq-row {
      padding: 15px;
    }
  }
}
</style>
